<!-- 用户数据按月份展示组件 -->
<template name='print_jcp'>
		<!-- 商品信息-右边 -->
		<view style="display: flex;    height: 100%;">
		
			<!-- 正在起动 -->
			<view class="onloadBox"  v-show="pageShow==false">
				<h3 id="onloadMsg" class="onload">
					正在起动...
				</h3>
				<view v-html="onloadMsg"></view>
			</view>
			<!-- end -->
			
			<!-- 核心区 01 02 模板-->
			<view class="box-infos font12  "  v-if="pageShow==true" >
				
				
				<view  id="Papers" v-if="onPrint == false">
					<view v-html="resData.body"></view>
					<view v-html="resData.zuijia_1"></view>
					<!-- <view v-html="resData.zuijia_2"></view> -->
				</view>
				
				
				
				
				<view class="boxsss100" v-if="onPrint == true">
					
					<view class="controls-panel" >
						<!-- 页眉 页脚 -->
						<uni-section class="uni-section" title="订货单据设置" type="line">
							
								<view class="floatleft flex">
									<view class="riskTitle">
										订货单据标题：
									</view>
									<input type="text" size="5" id="printHeader" class="input_confirms justify" 
									placeholder="例如：订货单" placeholder-class="placeholder-class"
									v-model="dinghuo.title"
									>
								</view>
								<view class="floatleft flex">
									<view class="riskTitle">
										收货地址：
									</view>
									<input type="text" size="5" id="printHeader" class="input_confirms justify" 
									placeholder="xxx省xxx市xxx镇xxxxxx" placeholder-class="placeholder-class"
									v-model="dinghuo.city"
									>
								</view>
								
								
								<view class="floatleft flex">
									<view class="riskTitle">
										收货联系人：
									</view>
									<input type="text" size="5" id="printHeader" class="input_confirms justify" 
									placeholder="陈xxx 138xxxxxxxxxxxx" placeholder-class="placeholder-class"
									v-model="dinghuo.name"
									>
								</view>
								
								
								<view class="floatleft flex">
									<view class="riskTitle">
										单据顶部显示信息：
									</view>
									<input type="text" size="5" id="printHeader" class="input_confirms justify" 
									placeholder="例如：主营三轮车配件、摩托车配件、电动车配件" placeholder-class="placeholder-class"
									v-model="dinghuo.header"
									>
								</view>
								<view class="floatleft flex">
									<view class="riskTitle">
										单据底部显示信息：
									</view>
									<input type="text" size="5" id="printBottom" class="input_confirms justify" 
									v-model="dinghuo.bottom" placeholder-class="placeholder-class"
									placeholder="例如：三轮车系列配件无三包">
									<button class="leftBut   color1"  @click="$common.noMultipleClicks('set_print_dinghuo',set_print_dinghuo)">
										保存生效
									</button>
								</view>
						
						</uni-section>
						<!-- end -->
										
						<!-- 页眉 页脚 -->
						<uni-section class="uni-section" title="销售单据设置" type="line">
							
							
							<view class="floatleft flex">
								<view class="riskTitle">
									打印单据内容模板:
								</view>
						
								<view class="ipu-box">
									<view class="input_confirms justify" style="margin-left: 0px;width: 150px;">
										<uni-data-select
										class=""
										:localdata="print_mode.list"
										v-model="print_mode.now_id"
										@change="PrintersModeChange"
										placeholder="选择内容模板"
										placeholder-class="placeholder-class"
										></uni-data-select>
									</view>
								</view>
							</view>
							<view class="floatleft flex">
								<view class="riskTitle">
									单据标题：
								</view>
								<input type="text" size="5" id="printHeader" class="input_confirms justify" 
								placeholder="例如：送货单" placeholder-class="placeholder-class"
								v-model="xiaoshou.title"
								>
							</view>
							<view class="floatleft flex">
								<view class="riskTitle">
									单据顶部显示信息：
								</view>
								<input type="text" size="5" id="printHeader" class="input_confirms justify" 
								placeholder="例如：主营三轮车配件、摩托车配件、电动车配件" placeholder-class="placeholder-class"
								v-model="xiaoshou.header"
								>
							</view>
							<view class="floatleft flex">
								<view class="riskTitle">
									单据底部显示信息：
								</view>
								<input type="text" size="5" id="printBottom" class="input_confirms justify" 
								v-model="xiaoshou.bottom" placeholder-class="placeholder-class"
								placeholder="例如：三轮车系列配件无三包">
								
								<button class="leftBut   color1" @click="$common.noMultipleClicks('set_print_xiaoshou',set_print_xiaoshou)">
									保存生效
								</button>
							</view>
						</uni-section>
						<!-- end -->
					</view>
					
					
				
					<uni-section class="uni-section" title="打印机的设置" type="line">
						<!-- 单据打印的设置 -->
						<view class="main" v-if="Papers.list.length>0">
							<view class="floatleft flex">
								<view class="riskTitle ">
									销售单据打印机：
								</view>
								<picker 
								@change="PrintersChange"
								:value="Printer.index" 
								range-key="text"
								class="input_confirms justify  h100"
								:range="Printer.list">
									<view class="uni-input">{{Printer.list[Printer.index].text }}</view>
								</picker>
							</view>
							
							<view class="floatleft flex">
								<view class="riskTitle ">
									打印纸：
								</view>
								<picker 
								@change="gradeChange"
								:value="Papers.index" 
								range-key="text"
								class="input_confirms justify h100"
								:range="Papers.list">
									<view class="uni-input">{{Papers.list[Papers.index].text }}</view>
								</picker>
							</view>
							
							
							<!-- 自定义宽高 -->
							<view class="floatleft flex"  v-if="Papers.pagesCreateShow">
								<view class="riskTitle ">
									纸张宽：
								</view>
								<input 
								type="number" 
								size="4"
								class="input_confirms justify h100" 
								placeholder-class="placeholder-class"
								placeholder="单位/mm"
								v-model="Papers.width"
								@input="inputElement('width')" 
								@confirm="inputElement('width')">
							</view>
							
							<view class="floatleft flex"  v-if="Papers.pagesCreateShow">
								<view class="riskTitle ">
									纸张高：
								</view>
								<input type="number" 
								size="4"
								class="input_confirms justify h100" 
								placeholder-class="placeholder-class"
								placeholder="单位/mm"
								style="text-align:left"
								v-model="Papers.height"
								@input="inputElement('height')" 
								@confirm="inputElement('height')"/>
							</view>
							
							<view class="floatleft flex">
								<view class="riskTitle ">
									纸张方向：
								</view>
								<picker
								@change="intOrientChange"
								:value="intOrient.index" 
								range-key="text"
								class="input_confirms justify h100"
								:range="intOrient.list">
									<view class="uni-input">{{intOrient.list[intOrient.index] }}</view>
								</picker>
							</view>
						
						</view>
											
						<!-- 商品标签打印的设置 -->
						<view class="main" title="商品标签打印设置" type="line">
							
							<view class="floatleft flex">
								<view class="riskTitle ">商品标签打印机：</view>
								<picker
								v-if="$print.Printer.list.length>0"
								@change="(e)=>{$print.PrintersChange(e),printGoodsPrinter.Printer.index=e.detail.value}"
								:value="printGoodsPrinter.Printer.index" 
								range-key="text"
								class="input_confirms justify h100"
								:range="printGoodsPrinter.Printer.list"
								>
									<view class="uni-input" >{{printGoodsPrinter.Printer.list[printGoodsPrinter.Printer.index].text }}</view>
								</picker>
							</view>
							<view class="floatleft flex">
								<view class="riskTitle ">打印纸：</view>
								<picker
								v-if="$print.Papers.list.length>0"
								@change="(e)=>{$print.gradeChange(e),printGoodsPapers.Papers.index=e.detail.value}"
								:value="printGoodsPapers.Papers.index" 
								range-key="text"
								class="input_confirms justify h100"
								:range="printGoodsPapers.Papers.list"
								>
									<view class="uni-input">{{printGoodsPapers.Papers.list[printGoodsPapers.Papers.index].text }}</view>
								</picker>
							</view>
							<!-- 内容 -->
							<view  class="floatleft flex" v-if="printGoodsPapers.Papers.index==0">
								<view class="riskTitle ">纸张宽：</view>
								<input 
								type="number" 
								size="4"
								class="input_confirms justify h100" 
								placeholder-class="placeholder-class"
								placeholder="单位/mm"
								v-model="$print.Papers.width"
								@input="$print.inputElement('bq_width')"
								@confirm="$print.inputElement('bq_width')"
								/>
								<!-- <view class="tips">
									小程序路径:开发者管理
								</view> -->
						
							
							<!-- 内容 -->
							</view>
							<view  class="floatleft flex" v-if="printGoodsPapers.Papers.index==0">
								<view class="riskTitle ">纸张高：</view>
								<input 
								type="number" 
								size="4"
								class="input_confirms justify h100" 
								placeholder-class="placeholder-class"
								placeholder="单位/mm"
								v-model="$print.Papers.height"
								@input="$print.inputElement('bq_height')"
								@confirm="$print.inputElement('bq_height')"
								/>
								<!-- <view class="tips">
									小程序路径:开发者管理
								</view> -->
							</view>
						</view>
						
						<!-- 货位标签打印的设置 -->
						<view class="main" title="货位标签打印设置" type="line">
							<view class="floatleft flex">
								<view class="riskTitle ">货位标签打印机：</view>
								<picker
								v-if="$print_position.Printer.list.length>0"
								@change="(e)=>{$print_position.PrintersChange(e),printPositionPrinter.Printer.index=e.detail.value}"
								:value="printPositionPrinter.Printer.index" 
								range-key="text"
								class="input_confirms justify h100"
								:range="printPositionPrinter.Printer.list"
								>
									<view class="uni-input" >{{printPositionPrinter.Printer.list[printPositionPrinter.Printer.index].text }}</view>
								</picker>
							</view>
						
							<view class="floatleft flex">
								<view class="riskTitle ">打印纸：</view>
								<picker
								v-if="$print_position.Papers.list.length>0"
								@change="(e)=>{$print_position.gradeChange(e),printPositionPapers.Papers.index=e.detail.value}"
								:value="printPositionPapers.Papers.index"
								range-key="text"
								class="input_confirms justify h100"
								:range="printPositionPapers.Papers.list"
								>
									<view class="uni-input">{{printPositionPapers.Papers.list[printPositionPapers.Papers.index].text }}</view>
								</picker>
							</view>
							
							
							<!-- 内容 -->
							<view class="floatleft flex" v-if="printPositionPapers.Papers.index==0">
								
								<view class="riskTitle ">纸张宽：</view>
								<input 
								type="number" 
								size="4"
								class="input_confirms justify h100" 
								placeholder-class="placeholder-class"
								placeholder="单位/mm"
								v-model="$print_position.Papers.width"
								@input="$print_position.inputElement('position_width')"
								@confirm="$print_position.inputElement('position_width')"
								/>
							</view>
							
							<view class="floatleft flex" v-if="printPositionPapers.Papers.index==0">
								<view class="riskTitle ">纸张高：</view>
								<input 
								type="number" 
								size="4"
								class="input_confirms justify h100" 
								placeholder-class="placeholder-class"
								placeholder="单位/mm"
								v-model="$print_position.Papers.height"
								@input="$print_position.inputElement('position_height')"
								@confirm="$print_position.inputElement('position_height')"
								/>
							</view>
						
						</view>
				
					</uni-section>
					
					<!-- 功能按钮 -->
					<view class="main contentSav" v-if="PrintOrderData.data==undefined">
						<button class="bu" @click="startLodop()" 
						v-if="isStart==false">
							启动打印服务
						</button>
						<button class="bu" @click="isStart=false,closeLodop()" 
						style="background-color: #a30000" 
						v-if="isStart==true">
							停止打印{{globalMsg}}
						</button>
						
					</view>
					<!-- end -->
					
					<!-- 其他提示 -->
					<view class="content contentSav font12" v-if="PrintOrderData.data==undefined">
						提示:需要管理员或拥有打印权限的账号进入此页面方可正常打印，员工+客户进入此页面无法打印
					</view>
					
					<view class="content contentSav font12" v-if="PrintOrderData.data==undefined">
						提示:全自动打印设置：只要在销售单中点击：打印 即可打印出来
					</view>
					
					<view class="content contentSav font12">
						提示:必须下载专业的
						<a href="/static/print/CLodop_Setup_for_Win64NT_6.623EN.exe">
							打印控件
						</a>
						安装完成后刷新网页方可正常打印
					</view>
					
					<!-- end -->
				</view>
			</view>
			<!-- end -->
		
		</view>
</template>

<script>
	import shopping_admin from "@/components/goods/goods.vue"
	var LODOP
	import {
		getLodop
	} from "utils/LodopFuncs.js"
	
	export default{
		name:'print_jcp',
		components: {
			shopping_admin
		},
		beforeCreate(){
			this.$options.components.shopping_admin = require('@/components/goods/goods.vue').default 
		},
		data(){
			return{
				// 标签 货位
				printGoodsPapers: {
				  Papers: {
					list: this.$print.Papers.list, // 绑定 list
					index: this.$print.Papers.index // 绑定 index
				  }
				},
								
				printGoodsPrinter: {
				  Printer: {
					list: this.$print.Printer.list, // 绑定 list
					index: this.$print.Printer.index // 绑定 index
				  }
				},
				
				
				printPositionPapers: {
				  Papers: {
					list: this.$print_position.Papers.list, // 绑定 list
					index: this.$print_position.Papers.index // 绑定 index
				  }
				},
							
				printPositionPrinter: {
				  Printer: {
					list: this.$print_position.Printer.list, // 绑定 list
					index: this.$print_position.Printer.index // 绑定 index
				  }
				},
				
				// 标签 货位 end
				onloadMsg:'',
				print_mode:{
					list:[
						{text:'销售单模板(默认)',value:'1'},
						{text:'销售单模板-底部留底',value:'2'},
						{text:'进货单模板',value:'3'},
					],
					now_id:'1'
				},
				intOrient:{
					list:['纵向打印(默认)','横向打印'],
					index:0,
				},
				isStart:false,//是否起动
				pageShow:false,//是否展示 核心区
				xiaoshou:{//页眉 页脚
					header:'',
					bottom:'',
					title:''
				},
				dinghuo:{
					title:'',
					city:'',
					name:'',
					header:'',
					bottom:'',
					title:''
				},
				timerCount:0,//计数器
				globalMsg:'',//全局MSG
				resData:{//打印数据
				},
				/**
				 * 打印机
				*/
				Papers:{
					list:[],//当前打印机的打印纸数组
					index:-1,//选中的打印纸索引
					height: 1400,//自定义的打印纸高度 单位mm
					width: 2410,//自定义的打印纸宽度 单位mm
					pagesCreateShow:false,//自定义纸张是否可见
					name:''
				},
				/**
				 * 打印纸
				*/
				Printer:{
					list:[],
					index:-1,
				},
			}
		},
		mounted() {
			
		},
		 // 此处定义传入的数据
		props: {
			PrintOrderData: {
				type: Object,
				default:() => {
					return {}
				}
			},
			onPrint: {
				type: Boolean,
				default:true
			}
		},
		created() {
			var that = this
			if(that.$common.isIE() == true){
				that.$common.showModal('提示','当前浏览器为IE浏览器，暂不支持运行')
				return 
			}
		
			//判断是否进货去打印的，如果是的话就不获取页眉了
			if(this.PrintOrderData.body!=undefined){
				this.resData = this.PrintOrderData
			}else{
				that.$common.get_request(
					{
						type:'GetXiaoshou',
					},
					(res)=>{
						that.xiaoshou = res.data
					}
				);
				that.$common.get_request(
					{
						type:'GetDinghuo',
					},
					(res)=>{
						that.dinghuo = res.data
					}
				);
			}
			if(that.onPrint == true){
				//起动打印服务
				this.checkLodop(function(){
					that.pageShow = true
					that.getStorage();//获取缓存记忆
				})
				this.getStorageInput()
			}else{
				//只查询单据无需启动打印服务
				that.pageShow = true
				//起动打印服务
				this.checkLodop(function(){
					that.getStorage();//获取缓存记忆
				})
				this.getStorageInput()
				
				
			}
			
		},
		methods:{
			/**
			 * 获取缓存宽高的记忆
			*/
			getStorageInput(){
				var that = this
				uni.getStorage({
					key:'height',
					success: (res) => {
						that.Papers.height = res.data
					}
				})
				uni.getStorage({
					key:'width',
					success: (res) => {
						that.Papers.width = res.data
					}
				})
				
				uni.getStorage({
					key:'intOrientValueKeyName',
					success: (res) => {
						that.intOrient.index= res.data
					}
				})
				
				
			},
			
			/**
			 * 保存自定义纸张的宽高
			*/
			inputElement(type){
				if(type =='height'){
					var value = this.Papers.height
				}else{
					var value = this.Papers.width
				}
				uni.setStorage({
					key: type,
					data: value,
					success: function () {
					}
				});
			},
			
			//纸张方向设置的回调
			intOrientChange(e){
				this.intOrient.index = e.detail.value,
				uni.setStorage({
					key: 'intOrientValueKeyName',
					data: e.detail.value,
					success: function () {
					}
				});
			},
			
			PrintersChange(e){
				this.Printer.index = e.detail.value,
				uni.setStorage({
					key: 'PrintersValueKeyName',
					data: e.detail.value,
					success: function () {
					}
				});
				that.getStorage();//获取缓存记忆
			},
			/**
			 * 设置打印纸缓存
			*/
			gradeChange(e){
				this.Papers.index = e.detail.value
				this.Papers.name =  this.Papers.list[this.Papers.index].text
				this.checkPapers();
				uni.setStorage({
					key: 'Print_Papers',
					data: this.Papers,
					success: function () {
					}
				});
			},
			
			/**
			 * 设置打印机缓存
			*/
			PrintersModeChange(e){
				uni.setStorage({
					key: 'Print_mode',
					data: e,
					success: function () {
					}
				});
			},
			
			/*
			* 检查是否选中的是自定义纸张，是的话就显示自定义宽高项
			*/
			checkPapers(){
				this.Papers.pagesCreateShow = this.Papers.index==0 ? true : false
			},
			
			
			/**
			 * 获取纸张、打印机都需要传递进去select的ID
			*/
			getStorage(){
				var that = this
				//上次记忆的打印机
				this.CreatePrinterList();//获取打印机
				var index = uni.getStorageSync('PrintersValueKeyName')//获取记忆
				//判断是否有记忆;有的话旧设置记忆的打印机
				if( index==''){
					this.Printer.index = 0 
				}else{
					
					this.Printer.index = Number.isInteger(index) ? index : 0 
				}


				that.Papers.list = []
				that.Papers.list.push({ value: 'CreateCustomPage', text: "自定义纸张" })
				
				var strPageSizeList = LODOP.GET_PAGESIZES_LIST(that.Printer.index,"|");
				var Options = strPageSizeList.split("|"); 
				
				Options.forEach(function(item,i){
					that.Papers.list.push({ value: item, text: item})
				})

				
				//
				var Papers = uni.getStorageSync('Print_Papers')//获取记忆
				
				if(Papers.index){
					this.Papers.index = Papers.index
					this.Papers.name  = Papers.name
				}else{
					this.Papers.index = 0
				}
				this.checkPapers();
				
				var data = uni.getStorageSync('Print_mode')//获取记忆
				this.print_mode.now_id = data.length<=0?'1':data
				
			},
			
			/**
			 * 获取打印机列表
			*/
			CreatePrinterList(){
				var iPrinterCount = LODOP.GET_PRINTER_COUNT();
				var option = {}
				for(var i=0;i<iPrinterCount;i++){
					option = {}
					option.value = i;
					option.text = LODOP.GET_PRINTER_NAME(i);
					this.Printer.list.push(option)
				};	
				this.Printer.index = 0
			},
			
			
			/**
			 * 停止打印服务
			*/
			closeLodop(){
				this.isStart = false
				this.$common.toast("已停止服务")
			},
			
			/**
			 * 起动打印服务
			*/
			startLodop(){
				this.isStart = true
				this.clock()
			},
				
			/**
			 * 预览打印
			*/
			PREVIEW(){
				if(this.resData.body==undefined){
					this.$common.showModal("当前无可预览的单据，请在下单页面发送单据打印即可在此处预览！")
					return
				}
				this.Prnt_Oneform(false,this.resData)
			},
		
			/**
			 * 判断当前LODOP是否就绪
			*/
			checkLodop(callFun){
				var that  = this
				var res = undefined;
				var TimerInit = setInterval(function() { //将计时器赋值给 TimerInit 
					res = getLodop();
					
					if (res.type==false) {
						
						if(res.clearInterval==true){
							that.onloadMsg = res.msg
							var data = document.getElementById("onloadMsg").innerHTML = res.msg
							console.log('data',data)
							clearInterval(TimerInit) 
							
						}
						
					} else {
						clearInterval(TimerInit) 
						LODOP = res.data
						callFun();
					}
				}, 100);
			},
		
			/**
			 * 保存销售打印页眉页脚
			*/
			set_print_xiaoshou(){
				var that = this
				
				that.$common.get_request(
					{
						type:'set_print_xiaoshou',
						header:that.xiaoshou.header,
						bottom:that.xiaoshou.bottom,
						title:that.xiaoshou.title,
					},
					(res)=>{
						uni.showModal({
							content: res.msg,
							success: function (res) {
							}
						});
					}
				);
			},
		
			/**
			 * 保存订货打印页眉页脚
			*/
			set_print_dinghuo(){
				var that = this
				
				that.$common.get_request(
					{
						type:'set_print_dinghuo',
						header:that.dinghuo.header,
						bottom:that.dinghuo.bottom,
						title:that.dinghuo.title,
						name:that.dinghuo.name,
						city:that.dinghuo.city,
					},
					(res)=>{
						uni.showModal({
							content: res.msg,
							success: function (res) {
							}
						});
					}
				);
			},
		
			/**
			 * 网络请求数据打印
			*/
			clock(){
				var that = this
				that.timerCount++;
				that.globalMsg = that.timerCount
				that.$common.get_request(
					{
						type:"order_print_list",
						print_mode:that.print_mode.now_id
					},
					(res)=>{
						
						if(res.body !=undefined){
							//延时不够======================导致第一张打印的是空白的
							//删除打印记录
							that.Prnt_Oneform(true,res)//LODOP打印
							console.log('res.print_order.voice',res.print_order.voice)
							if(res.print_order.voice == 1){
								
								console.log('res.print_order.voice','播报新打印语音')
								//播报新打印语音
								that.$voice.print_Play()
							}
						}else if(res.order_voice == 1){
								//播报新订单语音
								console.log('播报新订单语音')
								that.$voice.order_Play()
						}
					},()=>{
						if(that.isStart == true){
							//console.log("延时5秒钟")
							setTimeout(function() {
							//	console.log("延时5秒钟之后，继续运行...")
								that.clock()
							}, 10000);//间隔性定时器
						}
						
					},false,
				);

				that.$common.get_request(
					{type:"qrcode_print_list"},
					(res)=>{
						if(res.data !=undefined){
							if(res.data.type == 1){
								that.$print.printInit(res)
							}else{
								that.$print_position.printInit(res)
							}
						}
					},()=>{
					},false,
				);
				that.$common.get_request(
					{
						type:"getOrderType",
					},
					(res)=>{
						if(res.data !=undefined){
							that.Prnt_Oneform(true,res.data)//LODOP打印
						}
					},()=>{
						
					},false,
				);
			},
		
			/**
			 * 
			strPageName:所选纸张类型名，字符型。不同打印机所支持的纸张可能不一样，这里的名称同操作系统内打印机属性中的纸张名称，支持操作系统内的自定义纸张。
			关键字“CreateCustomPage”会按以上宽度和高度自动建立一个自定义纸张，所建立的纸张名固定为“LodopCustomPage”，多次建立则刷新该纸张的大小值。
			注：PageWidth、PageHeight 和strPageName都无效时，本函数对纸张大小不起作用，控件则采用所选打印机的默认纸张，但intOrient仍可起作用。
			实际打印时，控件按如下优先级顺序确定纸张大小：
			第1优先是打印维护里纸张属性（“本机自行定义纸张”）设置的纸张大小。
			第2优先是SET_PRINT_PAGESIZE指定的纸张大小； 
			第3优先是上次打印时在预览界面设置里选择的纸张类型；
			第4是按所选打印机的默认纸张； 
			*/
		  
		   
			Prnt_Oneform(PREVIEW,data,Papers=null,Printer=null,intOrient=null) {	
				var that = this
				LODOP = getLodop().data; 
				//var LODOP = that.LODOP
				//设置纸张
				var pageSetting = {};
				var PapersObj   = (Papers==null || Papers.width==undefined) ? that.Papers : Papers;
				var PrinterObj  = (Printer==null || Printer.index ==undefined) ? that.Printer : Printer;
				var intOrientObj = (intOrient==null || intOrient.index ==undefined) ? that.intOrient : intOrient;

				if(PapersObj.list[PapersObj.index].text=="自定义纸张"){
					console.log('自定义纸张',PapersObj)
					pageSetting.width    = parseFloat(PapersObj.width)
					pageSetting.height   = parseFloat(PapersObj.height)
					pageSetting.PageName = "CreateCustomPage";

				}else{
					console.log('ddd',PapersObj)
					pageSetting.width    = 0
					pageSetting.height   = 0
					pageSetting.PageName = PapersObj.name;
				}
				//------------------------------------end

				//动态设置纸张的方法，可以实现无间隔的连续打印输出
				LODOP.PRINT_INIT("");	
				
				//设定打印纸张为固定纸张或自适应内容高，并设定相关大小值或纸张名及打印方向。
				LODOP.SET_PRINT_PAGESIZE(intOrientObj.index+1,pageSetting.width,pageSetting.height,pageSetting.PageName);
				
				//对新建的纸张重命名
				LODOP.SET_PRINT_MODE("CREATE_CUSTOM_PAGE_NAME","摩配纸张");
				

				//打印主要表格内容-限定表格内容
				LODOP.ADD_PRINT_TABLE("0.2cm","0.2cm","RightMargin:0.2cm","BottomMargin:0.5cm",data.body);
				// end
				
				if(data.zuijia_1 && data.zuijia_1.length>0){
					LODOP.ADD_PRINT_HTM(
					"0",
					"0", 
					"RightMargin:0cm",
					"BottomMargin:0cm",
					data.zuijia_1
					);
							
					LODOP.SET_PRINT_STYLEA(0,"LinkedItem",-1);
				}


				if(data.zuijia_2 && data.zuijia_2.length>0){
					
					LODOP.ADD_PRINT_HTM(
					"0",
					"0", 
					"RightMargin:0cm",
					"BottomMargin:0cm",
					data.zuijia_2
					);
					
					// LODOP.SET_PRINT_STYLE("ItemType",1);
					// LODOP.SET_PRINT_STYLE("Vorient",1);
					LODOP.SET_PRINT_STYLEA(0,"PageIndex","Last");  //新加的内容项显示在倒数第1页
					
					
					
					//LODOP.SET_PRINT_STYLEA(0,"LinkedItem",-1);
				}
				//该打印项表格高是否含头脚
				LODOP.SET_PRINT_STYLEA(0,"TableHeightScope",1);	
				//指定打印机
				LODOP.SET_PRINTER_INDEX(PrinterObj.index)
				
				//区分预览或直接打印
				if(PREVIEW==false){
					
					LODOP.SET_PRINT_MODE("AUTO_CLOSE_PREWINDOW",1);//打印后自动关闭预览窗口
					//允许操作者在打印预览里重选。
					LODOP.SET_PRINT_MODE("RESELECT_PRINTER",true);
					LODOP.SET_PRINT_MODE("RESELECT_ORIENT",true);
					LODOP.SET_PRINT_MODE("RESELECT_PAGESIZE",true);
					LODOP.SET_PRINT_MODE("RESELECT_COPIES",true);
					// end
					LODOP.PREVIEW();
				}else{
					LODOP.PRINT();
				}		
			},
		
		},
	}
</script>

<style>
	@import "/static/css/print.css";

	.bu{
		background-color: #009434;
		color: #fff;
		font-weight: 400;
		justify-content: center;
		display: flex;
		height: 50px;
		flex-direction: column;
		justify-content: center;
	}
	.input_confirms{
		padding: 0px 10px;
	}
	.controls-panel {
		display: grid;
		grid-template-columns: repeat(2, 1fr);
	}
</style>
